package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.TiceForm;
import com.sample.javabean.Tice;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class TiceAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(TiceAction.class);
    	 	private Pager<Tice> pageList;
    	 	private String sno;
    	 	private Integer id;
    	 	private Tice tice=new Tice();
    	 	private TiceForm ticeForm=new TiceForm();
    	 	
    	 	
    	 	/**
    	 	 * 体测信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputTice()throws Exception{
    	 		
    	 		return "inputTice";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加体测信息");
    	 			if(ticeForm!=null){
    	 				Tice tice =new Tice();
    	 				 //将ticeForm中的属性值一一对应tice的对应属性
    	 				tice.setNname(ticeForm.getNname());
    	 				tice.setSex(ticeForm.getSex());
    	 				tice.setSno(ticeForm.getSno());
    	 				tice.setAge(ticeForm.getAge());
    	 				tice.setTtime(ticeForm.getTtime());
    	 				tice.setKg(ticeForm.getKg());
    	 				tice.setCm(ticeForm.getCm());
    	 				tice.setRun(ticeForm.getRun());
    	 				tice.setJump(ticeForm.getJump());
    	 				tice.setSit(ticeForm.getSit());
    	 				tice.setTree(ticeForm.getTree());
    	 				
    	 			   //调用方法
    	 				tice.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputTice";
    	 	}
    	 	
    	 	public String list()throws Exception{
    	 		Tice ticeModel =new Tice();
    	 		pageList =ticeModel.list(page, size, ticeForm);
    	 		return "listTice";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(ticeForm!=null){
    	 				tice.setSno(sno);
    	 				tice.delTice();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editTice()throws Exception{
    	 		try{
    	 			tice.setId(id);
    	 			tice.load();
    	 			return "editTice";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		log.info("sss");
    	 		try{
    	 			
    	 			if(ticeForm!=null){
    	 				tice.setId(ticeForm.getId());	
    	 				log.info("sss");
    	 				tice.setNname(ticeForm.getNname());
    	 				log.info("姓名");
    	 				tice.setSex(ticeForm.getSex());
    	 				log.info("性别");
    	 				tice.setSno(ticeForm.getSno());
    	 				log.info("学号");
    	 				tice.setAge(ticeForm.getAge());
    	 				log.info("年龄");
    	 				tice.setTtime(ticeForm.getTtime());
    	 				log.info("sss");
    	 				tice.setKg(ticeForm.getKg());
    	 				log.info("sss");
    	 				tice.setCm(ticeForm.getCm());
    	 				log.info("sss");
    	 				tice.setRun(ticeForm.getRun());
    	 				log.info("sss");
    	 				tice.setJump(ticeForm.getJump());
    	 				log.info("sss");
    	 				tice.setSit(ticeForm.getSit());
    	 				log.info("sss");
    	 				tice.setTree(ticeForm.getTree());
    	 				log.info("sss");
    	 				tice.editTice();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Tice> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Tice> pageList) {
				this.pageList = pageList;
			}
			public String getSno() {
				return sno;
			}
			public void setSno(String sno) {
				this.sno = sno;
			}
			public Integer getId() {
				return id;
			}
			public void setId(Integer id) {
				this.id = id;
			}
			public Tice getTice() {
				return tice;
			}
			public void setTice(Tice tice) {
				this.tice = tice;
			}
			public TiceForm getTiceForm() {
				return ticeForm;
			}
			public void setTiceForm(TiceForm ticeForm) {
				this.ticeForm = ticeForm;
			}
			public static Log getLog() {
				return log;
			}
			
			
    	
}
